//
//  HotCircleViewController.m
//  DefendHealth
//
//  Created by 吾诺翰卓003 on 17/2/18.
//  Copyright © 2017年 iMacOne. All rights reserved.
//

#import "HotCircleViewController.h"
#import "HotCircleTableViewCell.h"
#import "SelectedTopicViewController.h"
@interface HotCircleViewController ()

@end

@implementation HotCircleViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.Nav.hidden = YES;
    [self addHeadView];
    self.baseTableView.frame = CGRectMake(0, 0, WindowWidth, WindowHeight-64-49);
//    self.baseTableView.backgroundColor = [UIColor whiteColor];
//    self.view.backgroundColor = [UIColor whiteColor];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)addHeadView{
    UIView *headView1 = [UIView new];
    
    headView1.backgroundColor = [UIColor whiteColor];
    
    
    UILabel *lab1 = [UILabel new];
    lab1.frame = CGRectMake(10, 0, 118, 44);
    lab1.text = @"精选话题";
    lab1.font = FONT(13);
    lab1.textColor = UIColorFromRGB(0x333333);
    lab1.textAlignment = 0;
    [headView1 addSubview:lab1];
    
    UILabel *lab2 = [UILabel new];
    lab2.frame = CGRectMake(WindowWidth-118-10-7-10, 0, 118, 44);
    lab2.text = @"更多";
    lab2.font = FONT(13);
    lab2.textColor = UIColorFromRGB(0x333333);
    lab2.textAlignment = 2;
    [headView1 addSubview:lab2];
    
    UIImageView * weather = [ReduceCode creatImageVeiwWithFrame:CGRectMake(WindowWidth-10-7, 0, 7, 11) imageName:@"point" isCorner:NO];
    weather.centerY = lab2.centerY;
    [headView1 addSubview:weather];

    
    UIButton *SelectedTopicbtn1 = [[UIButton alloc] initWithFrame:CGRectMake(WindowWidth-80-25, 0, 80, 44)];
    [SelectedTopicbtn1 addTarget:self action:@selector(SelectedTopic) forControlEvents:UIControlEventTouchUpInside];
    
    [headView1 addSubview:SelectedTopicbtn1];
    
    for (int i = 0; i<2; i++) {
        UIImageView *img = [UIImageView new];
        img.frame = CGRectMake(10*(i+1)+(WindowWidth-10*3)/2*i, kMaxY(lab2.frame), (WindowWidth-10*3)/2, 80);
        img.backgroundColor = [UIColor grayColor];
        [headView1 addSubview:img];
    }
    
    UIView *hui = [UIView new];
    hui.frame = CGRectMake(0, kMaxY(lab2.frame)+80+24,WindowWidth , 5);
    hui.backgroundColor = kLineColor;
    [headView1 addSubview:hui];
    
    UILabel *lab3 = [UILabel new];
    lab3.frame = CGRectMake(10, kMaxY(hui.frame), 118, 44);
    lab3.text = @"推荐圈子";
    lab3.font = FONT(13);
    lab3.textColor = UIColorFromRGB(0x333333);
    lab3.textAlignment = 0;
    [headView1 addSubview:lab3];
    
    UILabel *lab4 = [UILabel new];
    lab4.frame = CGRectMake(WindowWidth-118-10-7-10, kMaxY(hui.frame), 118, 44);
    lab4.text = @"更多";
    lab4.font = FONT(13);
    lab4.textColor = UIColorFromRGB(0x333333);
    lab4.textAlignment = 2;
    [headView1 addSubview:lab4];
    
    UIImageView * weather2 = [ReduceCode creatImageVeiwWithFrame:CGRectMake(WindowWidth-10-7, 0, 7, 11) imageName:@"point" isCorner:NO];
    weather2.centerY = lab4.centerY;
    [headView1 addSubview:weather2];
    
    
    NSArray *titleArr = @[@"健身",@"饮食",@"养生",@"塑性"];
    for (int i = 0; i<4; i++) {
        UIImageView *img = [UIImageView new];
        img.frame = CGRectMake(10*(i+1)+(WindowWidth-10*5)/4*i, kMaxY(lab4.frame), (WindowWidth-10*5)/4, 50);
        img.backgroundColor = UIColorFromRGB(0xcccaca);
        [headView1 addSubview:img];
        
        UILabel *titilelab = [UILabel new];
        titilelab.frame = CGRectMake(0, 0, (WindowWidth-10*5)/4, 50);
        titilelab.text = titleArr[i];
        titilelab.font = FONT(13);
        titilelab.textColor = UIColorFromRGB(0x333333);
        titilelab.textAlignment = 1;
        [img addSubview:titilelab];
    }
    headView1.frame = CGRectMake(0, 0,WindowWidth , kMaxY(lab4.frame)+50+24);
    self.baseTableView.tableHeaderView = headView1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 226;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString * cellIden = @"HotCircleTableViewCell";
    HotCircleTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIden];
    if (cell == nil) {
        cell = [[HotCircleTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIden];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.backgroundColor = [UIColor whiteColor];
    return cell;
}
#pragma mark - 话题精选
-(void)SelectedTopic{
    SelectedTopicViewController *stVC = [SelectedTopicViewController new];
    stVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:stVC animated:YES];
}
@end
